
IF EXISTS(SELECT name FROM sys.databases WHERE name = 'DBDAYNGHE')
DROP DATABASE DBDAYNGHE
GO
CREATE DATABASE DBDAYNGHE
GO
USE DBDAYNGHE

/*-- CREATE TABLE TYPECATEGORY ----------- */
GO
CREATE TABLE TYPECATEGORY
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	[NAME] NVARCHAR(200) NOT NULL,
    [DESCRIPTION] NVARCHAR(300),
	SORTED INT,
	RECORD_STATUS BIT
)


/*-- CREATE TABLE CATEGORY ------------- */
GO
CREATE TABLE CATEGORY
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	[NAME] NVARCHAR(200) NOT NULL,
	TYPECATEID INT NOT NULL,	
	[DESCRIPTION] NVARCHAR(500),
	SORTED INT,
	RECORD_STATUS BIT
)

/*-- CREATE TABLE NEWS ------------- */
GO
CREATE TABLE NEWS
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	CATEID INT,
	TITLE NVARCHAR(300) NOT NULL,
	[IMAGE] NVARCHAR(300) NOT NULL,
	SUMMARY NTEXT,
	CONTENT NTEXT,
	AUTHORS NVARCHAR(50),
	CREATE_DATE DATETIME,
	SORTED INT,
	RECORD_STATUS BIT
)

/*-- CREATE TABLE MENUPARENT ------------- */
GO
CREATE TABLE MENUPARENT
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	URL NVARCHAR(500),
	[TARGET] NVARCHAR(50),
	SORTED INT,
	RECORD_STATUS BIT
)

/*-- CREATE TABLE MENUCHILD ------------- */

GO
CREATE TABLE MENUCHILD
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	PARENTID INT NOT NULL,
	URL NVARCHAR(500),
	[TARGET] NVARCHAR(50),
	SORTED INT,
	RECORD_STATUS BIT
)


/*-- CREATE TABLE SUPPORT ------------- */

GO
CREATE TABLE SUPPORT
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	[IMAGE] NVARCHAR(300) NOT NULL,	
	URL NVARCHAR(500),
	MOBILE 	NVARCHAR(50),
	SORTED INT,
	RECORD_STATUS BIT
)


/*-- CREATE TABLE ALBUM ------------- */

GO
CREATE TABLE ALBUM
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	[IMAGE] NVARCHAR(300) NOT NULL,
	SORTED INT,
	RECORD_STATUS BIT
)

/*-- CREATE TABLE IMAGE ------------- */
GO
CREATE TABLE [IMAGE]
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	ALBUMID INT NOT NULL,
	[IMAGE] NVARCHAR(300) NOT NULL,
	SORTED INT,
	RECORD_STATUS BIT
)


/*-- CREATE TABLE ADVERTISE ------------- */
GO
CREATE TABLE ADVERTISE
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	NAME NVARCHAR(200) NOT NULL,
	[IMAGE] NVARCHAR(300) NOT NULL,
	URL NVARCHAR(500),
	POSITION INT,
	SORTED INT,
	RECORD_STATUS BIT
)


/*-- CREATE TABLE ADMINISTRATOR ------------- */
GO
CREATE TABLE ADMINISTRATOR
(
	ID INT PRIMARY KEY IDENTITY(1,1),
	USERNAME NVARCHAR(50) NOT NULL,
	[PASSWORD] NVARCHAR(50) NOT NULL,
	RECORD_STATUS BIT
)